home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 22 / PC Actual CD 22.iso / SHARE / prog / POVRAY / STARFLD.ZIP / starfld.inc
Encoding:
Text File  |  1997-05-20  |  2.8 KB  |  66 lines

  1. // *****************************************************
  2. // STAR FIELD INCLUDE FILE FOR PERSISTENCE OF VISION 3.x
  3. // *****************************************************
  4. //
  5. // Created by Chris Colefax, May 1997
  6. //
  7. // OVERVIEW: Will create a three dimensional star field suitable
  8. // for animations.
  9. //
  10. // USAGE: To create the default star field just include this file
  11. // in your POV scene file.  You can customise the star field with
  12. // the following options:
  13. //
  14. //   #declare star_count = 1000
  15. //   #declare min_distance = 1000
  16. //   #declare max_distance = 5000
  17. //   #declare star_size = 2
  18. //   #declare star_seed = -4323
  19. //   #declare star_object = sphere {<0, 0, 0>, 20
  20. //      pigment {rgb <1, 1, 1>} finish {ambient 1}}
  21. //
  22. // Star_count is the number of stars to use in the star field.
  23. // Min and max_distance are relative to the origin, measured in
  24. // POVRay units.  Star_size can be used to increase/decrease the
  25. // size of the stars without having to declare the star_object
  26. // (eg. if changing the rendering resolution.  Star_seed is the
  27. // random seed used to create the star field.  Star_object is the
  28. // actual object used, and should be centred at the origin and
  29. // scaled large enough to be seen at the min and max_distances
  30. // specified (or you can use star_size to scale the star objects).
  31. //
  32. // You can create multiple star fields with different options by
  33. // including this file after declaring each set of options (note
  34. // that you don't have to redeclare options if they are the same
  35. // as those already used for a previous star field).
  36. //
  37. // You can modify the star field (eg. rotations, translations) by
  38. // including this file inside an object {} statement, eg:
  39. //
  40. //    object {#include " [filename here] " rotate y * clock * 360}
  41. //
  42. // ***************************************************************
  43.  
  44. // CHECK VARIABLES AND ASSIGN DEFAULTS
  45. // ***********************************
  46.    #ifndef (star_count) #declare star_count = 1000 #end
  47.    #ifndef (min_distance) #declare min_distance = 1000 #end
  48.    #ifndef (max_distance) #declare max_distance = min_distance * 5 #end
  49.    #declare _SF_distdif = max_distance - min_distance
  50.    #ifndef (star_size) #declare star_size = 1 #end
  51.    #ifndef (_SF_rand) #ifndef (star_seed) #declare _SF_rand = seed(0)
  52.       #else #declare _SF_rand = seed(star_seed) #end #end
  53.    #ifndef (star_object)
  54.       #declare star_object = disc {<0, 0, 0>, z, .5
  55.          pigment {onion color_map {[0 rgb 1.5] [1 rgb 0]} scallop_wave}
  56.          finish {ambient 1 diffuse 0} scale 50} #end
  57.  
  58. // CREATE STAR FIELD
  59. // *****************
  60.    union {#declare _SF_count = 0 #while (_SF_count < star_count)
  61.      object {star_object
  62.        scale star_size
  63.        translate z * (min_distance + rand(_SF_rand) * _SF_distdif)
  64.        rotate (<rand(_SF_rand),rand(_SF_rand),rand(_SF_rand)>-.5)*360}
  65.    #declare _SF_count = _SF_count + 1 #end }
  66.